{template 'public/header'}

{template 'public/comhead'}

<link rel="stylesheet" type="text/css" href="../addons/yzzc_sun/template/public/ygcss.css">

<ul class="nav nav-tabs">
    <span class="ygxian"></span>
    <div class="ygdangq">当前位置:</div>
    <li class="active"><a href="javascript:void(0);">车辆信息</a></li>
    <li><a href="{php echo $this->createWebUrl('goods');}"><i class="fa fa-refresh"></i>返回车辆列表</a></li>
</ul>
<div class="main ygmain">
    <form action="" method="post" class="form-horizontal form" enctype="multipart/form-data">
        <div class="panel panel-default ygdefault">
            <div class="panel-heading wyheader">
                车辆信息
            </div>
            <div class="panel-body">
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">选择门店</label>
                    <div class="col-sm-10">
                        <select name="sid">
                            <!--{if $nowshop['id']>0}-->
                            <!--<option value="{$nowshop['id']}">{$nowshop['name']}</option>-->
                            <!--{/if}-->
                            <option value="" selected="selected">请选择门店</option>
                            {loop $shop $sval}
                            {if $info['sid']==$sval['id']}
                            <option value="{$sval['id']}" selected="selected">{$sval['name']}</option>
                            {else}
                            <option value="{$sval['id']}">{$sval['name']}</option>
                            {/if}
                            {/loop}
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">车辆名称</label>
                    <div class="col-sm-9">
                        <input type="text" name="name" class="form-control" value="{$info['name']}" maxlength="20" />
                    </div>
                </div>
                <div class="form-group" style="width: 90%;margin-left: 15px;">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">车辆类型</label>
                    <div class="col-sm-10">
                        <select name="cartype">
                            {loop $cartype $val}
                            {if $info['cartype']==$val['id']}
                            <option value="{$val['id']}" selected="selected">{$val['name']}</option>
                            {else}
                            <option value="{$val['id']}">{$val['name']}</option>
                            {/if}
                            {/loop}
                        </select>
                    </div>
                </div>
                <div class="form-group" style="width: 90%;margin-left: 15px;">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">车辆品牌</label>
                    <div class="col-sm-10">
                        <select name="brand_id">
                            {loop $car_brand $val}
                            {if $info['brand_id']==$val['id']}
                            <option value="{$val['id']}" selected="selected">{$val['name']}</option>
                            {else}
                            <option value="{$val['id']}">{$val['name']}</option>
                            {/if}
                            {/loop}
                        </select>
                    </div>
                </div>
                <div class="form-group" style="width: 90%;margin-left: 15px;">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">车辆标签</label>
                    <div class="col-sm-10">
                        {loop $car_tag $val}
                        <input type="checkbox" name="tag_id[]" value="{$val['id']}" {if in_array($val['id'],$info['tag_id'])} checked {/if} >{$val['name']}</input>
                        {/loop}
                    </div>
                </div>
                <div class="form-group">
                    <div style='margin-left: 300px;margin-bottom: 10px;font-weight: bold;font-size: 20px;'>输入车牌号来代表库存，系统会按默认顺序进行出租</div>
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">车牌号</label>
                    <div class="col-sm-9">
                        <div class="input-group" style="width: 1000px;">
                            {if $sku}
                            {loop $sku $index $item}
                            <div class="actime" style="display: inline-block;width: 900px;">
                                <input class="form-control" type="text" name="carnum[]"  value="{$item['carnum']}" placeholder="请输入车牌号" style="display: inline-block;width:200px;">

                                <span style="width: 45px;display: inline-block;margin-left: 15px;">颜色</span>
                                <input type="text" name="colour[]" placeholder="输入颜色"  value="{$item['colour']}" style="width: 100px;display: inline-block;height: 35px;    padding: 6px 12px;border: 1px solid #ccc;border-radius: 1px;">

                                <span style="width: 45px;display: inline-block;margin-left: 15px;">排量</span>
                                <input type="text" name="displacement[]" placeholder="输入排量"  value="{$item['displacement']}" style="width: 100px;display: inline-block;height: 35px;    padding: 6px 12px;border: 1px solid #ccc;border-radius: 1px;">

                                <div style="width: 100px;display: inline-block;height: 30px;border-radius: 2px;">
                                    <button type="button" class="storespan btn btn-xs addSpec" style="height: 35px;width: 35px;margin-top: -1px;">添加</button>
                                    <button type="button" data-sku_id ="{$item['id']}" class="storespan btn btn-xs delSpec" style="height: 35px;width: 35px;margin-top: -1px;" >删除</button>
                                </div>
                                <input type="hidden" name="sku_id[]" class="sku_id" value="{$item['id']}">
                            </div>
                            {/loop}
                            {else}
                            <div class="actime" style="display: inline-block;width: 800px;margin-bottom: 2px;">
                                <input class="form-control" name="carnum[]"  placeholder="请输入车牌号" style="display: inline-block;width:200px;">

                                <div style="width: 45px;display: inline-block;margin-left: 15px;">颜色</div>
                                <input type="text" name="colour[]"  placeholder="输入颜色" style="width: 100px;display: inline-block;height: 35px;padding: 6px 12px;border: 1px solid #ccc;border-radius: 1px;">

                                <span style="width: 45px;display: inline-block;margin-left: 15px;">排量</span>
                                <input type="text" name="displacement[]" placeholder="输入排量" style="width: 100px;display: inline-block;height: 35px;    padding: 6px 12px;border: 1px solid #ccc;border-radius: 1px;">

                                <div style="width: 100px;display: inline-block;height: 30px;border-radius: 2px;position: absolute;">
                                    <button type="button" class="storespan btn btn-xs addSpec" style="height: 35px;width: 35px;margin-top: -1px;">添加</button>
                                    <button type="button" class="storespan btn btn-xs delSpec" style="height: 35px;width: 35px;margin-top: -1px;">删除</button>
                                </div>
                            </div>
                            {/if}

                        </div>
                    </div>
                </div>
<!--                <div class="form-group">-->
<!--                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">车牌号码</label>-->
<!--                    <div class="col-sm-9">-->
<!--                        <input type="text" name="carnum" class="form-control" value="{$info['carnum']}" />-->
<!--                    </div>-->
<!--                </div>-->
<!--                <div class="form-group">-->
<!--                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">车身颜色</label>-->
<!--                    <div class="col-sm-9">-->
<!--                        <input type="text" name="colour" class="form-control" value="{$info['colour']}" />-->
<!--                    </div>-->
<!--                </div>-->
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">车辆结构</label>
                    <div class="col-sm-10">
                        <input type="radio" value="1" name="structure" {if $info['structure']==1 || empty($info['structure'])}checked{/if} >两厢
                        <input type="radio" value="2" name="structure" {if $info['structure']==2}checked{/if} >三厢
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">变速箱</label>
                    <div class="col-sm-10">
                        <input type="radio" value="1" name="grarbox" {if $info['grarbox']==1 || empty($info['grarbox'])}checked{/if} >手动挡
                        <input type="radio" value="2" name="grarbox" {if $info['grarbox']==2 }checked{/if} >自动挡
                    </div>
                </div>
<!--                <div class="form-group">-->
<!--                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">汽车排量</label>-->
<!--                    <div class="col-sm-9">-->
<!--                        <input type="text" name="displacement" class="form-control" value="{$info['displacement']}" />-->
<!--                    </div>-->
<!--                </div>-->
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">承载人数</label>
                    <div class="col-sm-9">
                        <input type="number" name="num" class="form-control" value="{$info['num']}" />
                    </div>
                </div>
                <!--<div class="form-group">-->
                    <!--<label class="col-xs-12 col-sm-3 col-md-2 control-label">租金类型</label>-->
                    <!--<div class="col-sm-10">-->
                        <!--<input type="radio" value="1" name="moneytype" {if $info['moneytype']==1 || empty($info['moneytype'])}checked{/if} >日租-->
                        <!--<input type="radio" value="2" name="moneytype" {if $info['moneytype']==2 }checked{/if} >周租-->
                        <!--<input type="radio" value="3" name="moneytype" {if $info['moneytype']==3}checked{/if} >月租-->
                        <!--<input type="radio" value="4" name="moneytype" {if $info['moneytype']==4}checked{/if} >年租-->
                    <!--</div>-->
                <!--</div>-->
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">汽车日租金</label>
                    <div class="col-sm-9">
                        <input type="text" name="money" class="form-control" value="{$info['money']}" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">订单押金</label>
                    <div class="col-sm-9">
                        <input type="text" name="deposit" class="form-control" value="{$info['deposit']}" placeholder="0为不需要押金"/>
                    </div>
                </div>

                <!--
                                <div class="form-group" style="width: 90%;margin-left: 15px;">
                                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">租车简介</label>
                                    <div class="col-sm-10">
                                        <textarea name="content" class="form-control" cols="30" rows="7">{$info['content']}</textarea>
                                    </div>
                                </div>-->

                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">手续费</label>
                    <div class="col-sm-9">
                        <input type="text" name="fee" class="form-control" value="{$info['fee']}" />
                    </div>
                </div>
<!--                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">汽车日成本价</label>
                    <div class="col-sm-9">
                        <input type="text" name="cost_money" class="form-control" value="{$info['cost_money']}" />
                    </div>
                </div>-->
<!--                <div class="form-group">-->
<!--                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">限时活动价格</label>-->
<!--                    <div class="col-sm-9">-->
<!--                        <input type="text" name="act_money" class="form-control" value="{$info['act_money']}" placeholder="如无活动可不填" />-->
<!--                    </div>-->
<!--                </div>-->
                <div class="form-group">
                    <div style='margin-left: 300px;margin-bottom: 10px;font-weight: bold;font-size: 20px;'>*请按照‘yyyy-MM-dd’的格式填写时间，如2019-10-01</div>
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">活动时间</label>
                    <div class="col-sm-9">
                        <div class="input-group" style="width: 1000px;">
                            {if $info['subscribe_duration']}
                            {loop $spec $index $item}
                            <div class="actime" style="display: inline-block;width: 900px;">
                                <input class="form-control" name="subscribe_duration[]"  value="{$item['spec']}" id="" placeholder="请按照‘yyyy-MM-dd’的格式填写时间，如2019-10-01" style="display: inline-block;width:400px;">
                                <!-- <input type="text" class="form-control" name="subscribe_duration[]" value="{$item['spec']}" class="astime" placeholder="请按照‘yyyy-MM-dd’的格式填写时间，如2019-10-01" style="display: inline-block;width:400px;"> -->
                                <!-- {php echo tpl_form_field_date('subscribe_duration[]');} -->

                                <span style="width: 50px;display: inline-block">价格</span>
                                <input type="text" name="price[]" placeholder="输入价格"  value="{$item['price']}" style="width: 100px;display: inline-block;height: 30px;border-radius: 2px;">
                                <div style="width: 100px;display: inline-block;height: 30px;border-radius: 2px;">
                                    <button type="button" class="storespan btn btn-xs addSpec" style="height: 35px;width: 35px;margin-top: -1px;">添加</button>
                                    <button type="button" class="storespan btn btn-xs delSpec" style="height: 35px;width: 35px;margin-top: -1px;">删除</button>
                                </div>
                            </div>
                            {/loop}
                            {else}
                            <div class="actime" style="display: inline-block;width: 800px;margin-bottom: 2px;">
                                <input class="form-control" name="subscribe_duration[]"  value="" id="" placeholder="请按照‘yyyy-MM-dd’的格式填写时间，如2019-10-01" style="display: inline-block;width:400px;">
                                <!-- <input type="text" class="form-control" name="subscribe_duration[]" value="{$item['spec']}" class="astime" placeholder="请按照‘yyyy-MM-dd’的格式填写时间，如2019-10-01" style="display: inline-block;width:400px;"> -->
                                <!-- {php echo tpl_form_field_date('subscribe_duration[]');} -->
                                

                                <div style="width: 50px;display: inline-block;margin-left: 20px;">价格</div>
                                <input type="text" name="price[]"  placeholder="输入价格" style="width: 100px;display: inline-block;height: 30px;border-radius: 2px;">
                                <div style="width: 100px;display: inline-block;height: 30px;border-radius: 2px;">
                                    <button type="button" class="storespan btn btn-xs addSpec" style="height: 35px;width: 35px;margin-top: -1px;">添加</button>
                                    <button type="button" class="storespan btn btn-xs delSpec" style="height: 35px;width: 35px;margin-top: -1px;">删除</button>
                                </div>
                            </div>
                            {/if}

                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label  class="col-xs-12 col-sm-3 col-md-2 control-label">是否使用独立押金</label>
                    <div class="col-sm-9">
                        <label class="radio-inline">
                            <input type="radio" id="depositway1" name="depositway" value="1" {if $info['depositway']=='1' || empty($info['depositway'])}checked{/if} />
                            <label for="depositway1">是</label>
                        </label>
                        <label class="radio-inline">
                            <input type="radio" id="depositway2" name="depositway" value="0" {if $info['depositway']=='0'}checked{/if} />
                            <label for="depositway2">否</label>
                        </label>
                        <span class="help-block">*不使用独立押金，则使用平台设置的总押金。</span>
                    </div>
                </div>


<!--                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">基础服务费</label>
                    <div class="col-sm-9">
                        <input type="text" name="service_fee" class="form-control" value="{$info['service_fee']}" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">尊享服务费</label>
                    <div class="col-sm-9">
                        <input type="text" name="zx_service_fee" class="form-control" value="{$info['zx_service_fee']}" />
                    </div>
                </div>-->
<!--                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">是否推荐至首页</label>
                    <div class="col-sm-10">
                        <input type="radio" value="1" name="rec" {if $info['rec']==1 || empty($info['rec'])}checked{/if} >是
                        <input type="radio" value="2" name="rec" {if $info['rec']==2}checked{/if}>否
                    </div>
                </div>-->
<!--                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">是否热门车</label>
                    <div class="col-sm-10">
                        <input type="radio" value="1" name="hot" {if $info['hot']==1 || empty($info['hot'])}checked{/if} >是
                        <input type="radio" value="0" name="hot" {if $info['hot']==2}checked{/if}>否
                    </div>
                </div>-->
                <div class="form-group">
                    <label  class="col-xs-12 col-sm-3 col-md-2 control-label">是否开启车辆续租</label>
                    <div class="col-sm-9">
                        <label class="radio-inline">
                            <input type="radio" id="open_xz1" name="open_xz" value="1" {if $info['open_xz']=='1' || empty($info['open_xz'])}checked{/if} />
                            <label for="open_xz1">开启</label>
                        </label>
                        <label class="radio-inline">
                            <input type="radio" id="open_xz2" name="open_xz" value="0" {if $info['open_xz']=='0'}checked{/if} />
                            <label for="open_xz2">关闭</label>
                        </label>
                        <span class="help-block">*全局开启后，此开关才有效。</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">交易手续费</label>
                    <div class="col-sm-9">
                        <input type="text" name="platform_fee" class="form-control" value="{$info['platform_fee']}" />
                        <span class="help-block">交易手续费：车辆出租后产生的交易总金额 * 交易手续费，不设置则默认统一</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">汽车图片</label>
                    <div class="col-sm-9">
                        {php echo tpl_form_field_image('pic', $info['pic']);}
                        <span class="help-block">*建议比例 335*185</span>
                    </div>
                </div>
      </div>
  </div>
        <div class="form-group">

            <input type="submit" name="submit" value="保存设置" class="btn col-lg-3" style="color: white;background-color: #444444;margin-left: 550px;"/>

            <input type="hidden" name="token" value="{$_W['token']}" />
             <input type="hidden" name="id" value="{$info['id']}" />

        </div>

    </form>

</div>
<script type="text/javascript">
    $(function(){
        $("#frame-7").show();
        $("#yframe-7").addClass("wyactive");

    })
    layui.use('laydate', function () {
        var laydate = layui.laydate;
        laydate.render({
            elem: '.astime',
            type: 'datetime'
        });

    });
    $(document).ready(function(){
        //点击追加
        $('.input-group').on('click','.addSpec',function () {
            //1.把当前的tr克隆一份
            $(this).parents('.actime .sku_id').val('');
            var newTr = $(this).parents('.actime').clone();
            //2.追加
            newTr.find('input[type="text"]').val('');
            newTr.find('input[type="hidden"]').val('');
            $(this).parents('.actime').after(newTr);
        })
        //删除
        $(".input-group").on("click",".delSpec",function(){
            var sku_id = $(this).data('sku_id');
            $.ajax({
                type:"post",
                url:"{php echo $this->createWebUrl('goodsinfo',array('op'=>'deleteSku'))}",
                dataType:"json",
                data:{sku_id:sku_id},
                success:function(data){
                    if(data.code == 1){
                        $(this).parents('.actime').remove();
                    }else{
                        alert(data.msg)
                    }
                }
            })

        });

    })
</script>